package com.lanyou.esb.cook.proxy.service.push.impl;

import com.lanyou.esb.cook.proxy.entity.StoreForward;
import com.lanyou.esb.cook.proxy.redis.proxy.impl.StoreForwardJedisProxy;
import com.lanyou.esb.cook.proxy.redis.proxy.impl.StoreForwardKeysJedisProxy;
import com.lanyou.esb.cook.proxy.service.push.Push;

/**
 * 存储转发消息推送服务
 * 
 * @author Davey.wu
 */
public class StoreForwardPushImpl extends BasePush<StoreForward> implements
		Push<StoreForward> {

	/** 存储转发统计表Redis操作代理 **/
	private StoreForwardJedisProxy jedisProxy;
	/** 存储转发统计表键值Redis操作代理 **/
	private StoreForwardKeysJedisProxy storeForwardKeysJedisProxy;

	@Override
	public void pushToRedis(StoreForward reqForward) throws Exception {
		if (reqForward == null) {
			return;
		}

		String key = jedisProxy.getKeyFromObject(reqForward);
		// 保存键值
		storeForwardKeysJedisProxy.saddAsStr(
				storeForwardKeysJedisProxy.getKey(), key);
		// 将跟踪信息存入REDIS
		jedisProxy.setex(key, reqForward);

	}

	public StoreForwardJedisProxy getJedisProxy() {
		return jedisProxy;
	}

	public void setJedisProxy(StoreForwardJedisProxy jedisProxy) {
		this.jedisProxy = jedisProxy;
	}

	public StoreForwardKeysJedisProxy getStoreForwardKeysJedisProxy() {
		return storeForwardKeysJedisProxy;
	}

	public void setStoreForwardKeysJedisProxy(
			StoreForwardKeysJedisProxy storeForwardKeysJedisProxy) {
		this.storeForwardKeysJedisProxy = storeForwardKeysJedisProxy;
	}
	
}
